<script>
export default {
  name: "h"
}
</script>

<template>
<h1>猜数字小游戏</h1>
  <input type="text" v-model="num" placeholder="请输入你要猜的数字">
  <button @click="check">猜一猜</button>
  <h3>运算结果：{{result}}</h3>
</template>
<script setup>
import {ref} from "vue";

const result = ref('');
const num =ref('');

let x = parseInt(Math.random()*100)+1;
console.log(x);
const check = () => {
  if(num.value>x){
    result.value = '猜大了';
  }else if(num.value<x){
    result.value = '猜小了';
  }else{
    result.value = '猜对了';
  }
}
</script>

<style scoped>

</style>